/*
 * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.xuexiang.xdlink.component.command.impl;

import com.xuexiang.xdlink.component.command.IProtocolCommand;

/**
 * 简单的协议命令
 *
 * @author xuexiang
 * @since 2018/8/27 上午1:47
 */
public class ProtocolCommand<T> implements IProtocolCommand {

    /**
     * 发送命令的类型
     */
    private int mType;
    /**
     * 命令携带的内容
     */
    private T mContent;

    /**
     * 命令执行的延迟时间
     */
    private long mDelayTime = 0;

    public ProtocolCommand(int type) {
        mType = type;
    }

    public ProtocolCommand(int type, T content) {
        mType = type;
        mContent = content;
    }

    public ProtocolCommand setType(int type) {
        mType = type;
        return this;
    }

    public ProtocolCommand setContent(T content) {
        mContent = content;
        return this;
    }

    public ProtocolCommand<T> setDelayTime(long delayTime) {
        mDelayTime = delayTime;
        return this;
    }

    @Override
    public int getType() {
        return mType;
    }

    @Override
    public T getContent() {
        return mContent;
    }

    @Override
    public long getDelayTime() {
        return mDelayTime;
    }

    @Override
    public boolean isDelayCommand() {
        return mDelayTime != 0;
    }
}
